package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.dto.ProductDetailDto;
import com.cskaoyan.shopping.dto.AllProductResponse;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.dto.ProductCateDto;
import com.cskaoyan.shopping.form.PageRequest;
import com.cskaoyan.shopping.service.IProductCateService;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @ClassName:ShoppingControllerLei
 * @Description:TODO
 * @author:leiwenjie
 * @date:2022/9/20 21:24
 * @version:1.0
 */
@RestController
public class ShoppingControllerLei {

    @Autowired
    IProductCateService iProductCateService;

    @Autowired
    IProductService productService;


    @GetMapping("/shopping/categories")
    public ResponseData getCategories() {

        List<ProductCateDto> allProductCate = iProductCateService.getAllProductCate();

        return new ResponseUtil().setData(allProductCate);
    }

    @GetMapping("/shopping/product/{id}")
    public ResponseData getProductDetail(@NotNull @PathVariable("id") Long productId) {
        ProductDetailDto productDetail = productService.getProductDetail(productId);
        return new ResponseUtil().setData(productDetail);
    }

    @GetMapping("/shopping/goods")
    public ResponseData getGoodsList(PageRequest pageInfo) {

        AllProductResponse allProduct = productService.getAllProduct(pageInfo);


        return new ResponseUtil().setData(allProduct);
    }

    @GetMapping("/shopping/recommend")
    public ResponseData queryRecommendGoods() {
        List<PanelDto> recommendGoods = productService.getRecommendGoods();

        return new ResponseUtil().setData(recommendGoods);
    }


}
